package org.fujene.term;

import org.chasen.mecab.Node;
import org.chasen.mecab.Tagger;
import org.fujene.structure.Term;
import org.fujene.structure.TermList;

public class MecabChopper implements Chopper {
	private static final String stopWord = " 　！!＄$％%’\'（(）)、,。.・／/￥\\；;：:「[{」]}＠@＜<＞>～~";
	
	static{
		System.loadLibrary("MeCab");
	}
	
	@Override
	public TermList chop(String content) {
		Tagger tagger = new Tagger();

		Node node = tagger.parseToNode(content);

		TermList terms = new TermList(node.getLength());

		node = node.getNext();
		while (node.getNext() != null) {
			if(!stopWord.contains(node.getSurface()))
				terms.add(new Term(node.getSurface()));
			
			node = node.getNext();
		}

		return terms;
	}

}
